package cn.gs.serializable.entity;

// @author gs
import cn.gs.util.stream.TokenReader;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;

public class EntityController {

    public IEntity read(Reader reader) throws IOException {
        return read(new TokenReader(reader, "[]{},\":"));
    }

    public IEntity read(TokenReader reader) throws IOException {
        MapEntity a = new MapEntity();
        if (a.read(this, reader)) {
            return a;
        }
        ArrayEntity b = new ArrayEntity();
        if (b.read(this, reader)) {
            return b;
        }
        OneEntity c = new OneEntity();
        if (c.read(this, reader)) {
            return c;
        }
        return null;
    }
}
